{extend name="./base" /}

{block name="body"}

<form class="layui-form model-form" id="thisForm">
	{:tpl_fourth_menu()}

	<!-- 基础设置 -->
	<fieldset class="layui-elem-field layui-field-title">
		<legend>基础设置</legend>
	</fieldset>
	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">上传大小</label>
		<div class="layui-input-inline">
			<input name="form[size_limit]" class="layui-input" lay-verify="required" value="{$data['size_limit'] ?? ''}"/>
		</div>
		<div class="layui-form-mid">单位:MB,为0或者为空则不限制</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">文件后缀</label>
		<div class="layui-input-block">
			<input name="form[ext]" class="layui-input" value="{$data['ext'] ?? ''}" />
		</div>
		<div class="layui-input-block layui-word-aux">设置允许上传的文件后缀名，多个后缀名之间用“,”隔开，如不填则为不限制</div>
	</div>

	<!-- 缩略图 -->
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 80px;">
		<legend>上传方式</legend>
	</fieldset>
	<div class="layui-form-item">
		<label class="layui-form-label">上传方式</label>
		<div class="layui-input-inline">
			<select name="form[type]">
				{foreach $type as $key=>$val}
				<option value="{$key}" {if $key == $data['type']}selected{/if}>{$val}</option>
				{/foreach}
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-filter="formSubmit" lay-submit>保存</button>
			<button class="layui-btn layui-btn-primary" type="reset" >重置</button>
		</div>
	</div>
</form>
{/block}

{block name="script"}
<script>
	layui.use(['layer', 'form', 'table'], function () {
		var $ = layui.jquery, form= layui.form;

		// 表单提交
		form.on('submit(formSubmit)', function (data) {
			let formData = data.field;
			$.post('/admin/upload/config', formData, function(res){
				window.location.reload();
			})
			return false;
		});
	})
</script>
{/block}